import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";


// console.warn("本项目菜单路由",window.admin_config);
//表格展示与筛选
// 富文本编辑器
// import CKEditor from "@ckeditor/ckeditor5-vue2";
// Vue.use(CKEditor);
// 富文本编辑器 开始
// import tinymce from "tinymce";
// import VueTinymce from "@packy-tang/vue-tinymce";
// Vue.prototype.$tinymce = tinymce; // 将全局tinymce对象指向给Vue作用域下
// Vue.use(VueTinymce); // 安装vue的tinymce组件
// 富文本编辑器 结束

import "@/config/style/css-reset.css"; // css reset

import ElementUI from "element-ui";
import {
	Loading
} from "element-ui";
import {
	Message
} from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
// Vue.use(ElementUI, { size: "mini" });
Vue.use(ElementUI, {
	size: "small"
});

import * as dayjs from "dayjs";
Vue.prototype.$dayjs = dayjs; //

//axios
import request from "@/plugins/request.js";
Vue.prototype.$api = request.api;
Vue.prototype.$apiUploadImage = request.apiUploadImage;
Vue.prototype.$apiUploadVideo = request.apiUploadVideo;
Vue.prototype.$apiUploadFile = request.apiUploadFile;

import log from "@/plugins/log.js";
Vue.prototype.$logjson = log.logjson;
Vue.prototype.$log = log.logjson;

import Directives from "./directives"; //全局指令
Vue.use(Directives);

// import * as filters from "@/filters/index"; //全局过滤器
// Object.keys(filters).forEach((key) => {
// 	Vue.filter(key, filters[key]);
// });

// 混入
import _mixin from "@/mixins/index.js";
Vue.mixin(_mixin);

Vue.prototype.$load = {
	loading: null,
	open: function() {
		this.loading = Loading.service({
			fullscreen: true,
		});
	},
	close: function() {
		if (!this.loading) return false;
		this.loading.close();
	},
};

// 提示
let duration = 1500; //提示时长
window.alert = function(res = {}) {
	console.log("= alert =");

	if (typeof res == "object") {
		let {
			msg,
			code
		} = res;
		if (code == 200) {
			Message.success({
				message: msg,
				offset: 300,
				duration: duration,
			});
		} else {
			Message.error({
				message: msg,
				offset: 300,
				duration: duration,
			});
		}
	} else if (typeof res == "string") {
		Message.info(res);
	}
};
window.alertSucc = function(message) {
	console.log("= alertSucc =");
	Message.success({
		message: message,
		offset: 300,
		duration: duration,
	});
};
window.alertErr = function(message) {
	console.log("= alertErr =");
	Message.error({
		message: message,
		offset: 300,
		duration: duration,
	});
};
window.alertInfo = function(message) {
	console.log("= alertInfo =");
	Message.info({
		message: message,
		offset: 300,
		duration: duration,
	});
};



Vue.prototype.$message = Message;
Vue.config.productionTip = false;

new Vue({
	router,
	store,

	render: (h) => h(App),
}).$mount("#app");